public class test6 {
    private static int count = 0;

    public static void main(String[] args) {

        hanio(3, 'x', 'y', 'z');
        System.out.println(" 总共移动了 " + count + " 次");
    }
    public static void hanio(int n, char x, char y, char z) {
        count++;
        if(n==1) {
            move(x,n,z);
        }else {
            hanio(n-1,x,z,y);
            move(x,n,z);
            hanio(n-1,y,x,z);
        }

    }
    private static void move(char x, int n, char y) {
        System.out.println(" Move " + n + " from " + x + " to " + y);
    }

}


